﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;

namespace Logistics.DataAccess
{
    /// <summary>
    /// 获取数据的默认值
    /// </summary>
    public static class DBValue
    {
        /// <summary>
        /// 判断字符串是否为空.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static object GetDBValue(string value)
        {
            if (string.IsNullOrEmpty(value))
                return DBNull.Value;
            else
                return value;
        }
        /// <summary>
        /// 判断日期是否为空.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static object GetDBValue(DateTime value)
        {
            //if (value == DateTime.MinValue)
            //    return DBNull.Value;
            //else
            return value;
        }

        /// <summary>
        /// 判断日期是否为空.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static object GetDBValue(DateTime? value)
        {
            if (!value.HasValue)
                return DBNull.Value;
            else
                return value;
        }
        /// <summary>
        /// 判断全球唯一标识符是否为空.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static object GetDBValue(Guid value)
        {
            if (value == Guid.Empty)
                return DBNull.Value;
            else
                return value;
        }
    }
}
